-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Casting to Double of CGFloat.native for math functions #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
By curiosity, it couldn't be [edit]
|
@johnno1962, actually, this PR should not be necessary for any 32-bit platform. See: This overlay renames acosf to acos, etc., so that |
This is what @phausler has been saying all along. So something is wrong with my/the Android swift toolchain/stdlib? Any ideas? I followed the recipe here: https://github.com/apple/swift/blob/master/docs/Android.md.. Rebuilding from scratch... |
Hmm. I'm not in a position to try this myself, but:
|
If both of those work but "print(acos(CGFloat(0.5 as Float).native))" doesn't, then the code might be missing an "#if os(Android)" somewhere in CGFloat or a related file; otherwise, if one of those steps doesn't work, it's might be a similar problem with Float, the tgmath overlay, or something else in that arena... |
I think, this is because @johnno1962 Oh, you already tried that in #622. Never mind. |
(based on #632) |
A bit of trouble with the rebuild: |
A little more progress. After a complete rebuild the CGFloat.swift problems have disappeared while the NSGeometry.swift casting is still required as values are being assigned from a Float to a Double on 32 bits despite tgmath adapting to the argument type. Something like #632 is probably required. Foundation/NSGeometry.swift:464:40: error: cannot convert value of type 'CGFloat.NativeType' (aka 'Float') to expected argument type 'Double' |
Values of CGFloat.native need to be cast to Double before being passed to math functions. This PR is in preparation for the Android port of Foundation in PR #622. There is a question about whether this conversion should be necessary however as CGFloat.swift is derived from code that builds on other 32 bit platforms as is discussed in the Foundation for Android PR. It’s certainly required on Android.